package bavaria.hightech.b2b;

import java.util.Hashtable;
import java.util.Map;

public class BankRegistry {
	private static BankRegistry bankMapInstance;
	private Map<String, IB2B> bankMap;
	
	private BankRegistry(){
		bankMap = new Hashtable<String, IB2B>();
	}
	
	/**
	 * Implementation of a singleton-pattern for the bank registry
	 * @return instance of the bank registry
	 */
	public static BankRegistry getInstance(){
		if (bankMapInstance == null)
			bankMapInstance = new BankRegistry();
		
		return bankMapInstance;	
	}
	
	public void bind (String bankName, IB2B bank){
		if (bankMap.get(bankName) == null)
			bankMap.put(bankName, bank);
	}
	
	public IB2B lookup (String bankName){
		return bankMap.get(bankName);
	}
}
